//
//  ShopGoodInfoTableViewCell.m
//  BaseFrame
//
//  Created by 孟学浩 on 2017/5/19.
//  Copyright © 2017年 com.mxh. All rights reserved.
//

#import "ShopGoodInfoTableViewCell.h"

@interface ShopGoodInfoTableViewCell()


@end

@implementation ShopGoodInfoTableViewCell

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
        self.selectionStyle = 0;
        _imgView = [UIImageView new];
        _imgView.backgroundColor = getColor(@"f1f2f6");
        _imgView.contentMode = 2;
        _imgView.layer.masksToBounds = YES;
        
        _deleteButton = [[UIButton alloc]init];
        [_deleteButton setImage:[UIImage imageNamed:@"clear_button"] forState:UIControlStateNormal];
        [_deleteButton addTarget:self action:@selector(deleteButtonClick) forControlEvents:UIControlEventTouchUpInside];
        [self.contentView addSubview:_deleteButton];
        [self.contentView addSubview:_imgView];
    }
    return self;
}

- (void)layoutSubviews{
    [super layoutSubviews];
    _imgView.frame = CGRectMake(36 / WIDTH_5S_SCALE, 5 / WIDTH_5S_SCALE, SCREEN_WIDTH-72 / WIDTH_5S_SCALE, self.height-10);
    _deleteButton.frame = CGRectMake(36 / WIDTH_5S_SCALE + SCREEN_WIDTH - 72 / WIDTH_5S_SCALE , 0 / WIDTH_5S_SCALE, 20 / WIDTH_5S_SCALE, 20 / WIDTH_5S_SCALE);
}

- (void)setModel:(NSString *)model{
    _model = model;
    [self.imgView sd_setImageWithURL:[NSURL URLOffsetIPWithString:model]];
}

- (void)setSdImage:(UIImage *)sdImage{
    _sdImage = sdImage;
    self.imgView.image = sdImage;
}

- (void)deleteButtonClick{
    if (_getDeleteClick) {
        _getDeleteClick();
    }
}

@end
